package com.sm.healthy.adapter

import android.graphics.Color
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.sm.healthy.R
import com.sm.healthy.data.bean.EcgEntity
import com.sm.healthy.data.bean.OxygenEntity
import com.sm.healthy.databinding.ItemHistoryEcgBinding
import com.sm.healthy.databinding.ItemHistoryOxygenBinding

/**
 * 历史数据列表
 */
class HistoryEcgAdapter(
    layoutId: Int = R.layout.item_history_ecg,
    list: MutableList<EcgEntity> = arrayListOf()
) : BaseQuickAdapter<EcgEntity, BaseDataBindingHolder<ItemHistoryEcgBinding>>(
    layoutId,
    list
) {

    override fun convert(
        holder: BaseDataBindingHolder<ItemHistoryEcgBinding>,
        item: EcgEntity
    ) {
        holder.dataBinding?.ecgValue = item

        when {
            item.heartRate <= 60 -> {
                holder.dataBinding?.textView14?.text = "↓"
                holder.dataBinding?.textView14?.setTextColor(Color.parseColor("#00aa11"))
            }
            item.heartRate in 61..99 -> {
                holder.dataBinding?.textView14?.text = ""

            }
            item.heartRate > 100 -> {
                holder.dataBinding?.textView14?.text = "↑"
                holder.dataBinding?.textView14?.setTextColor(Color.parseColor("#de253b"))
            }
        }
        /*when {
            item.levelPul <= 60 -> {
                holder.dataBinding?.textView9?.text = "↓"
                holder.dataBinding?.textView9?.setTextColor(Color.parseColor("#00aa11"))
            }
            item.levelPul in 61..99 -> {
                holder.dataBinding?.textView9?.text = ""
            }
            item.levelPul > 100 -> {
                holder.dataBinding?.textView9?.text = "↑"
                holder.dataBinding?.textView9?.setTextColor(Color.parseColor("#de253b"))
            }
        }*/
    }
}